package servlets;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import dto.itemComandaDTO;



/**
 * Servlet implementation class GenerarComandaConCantidad
 */

public class GenerarComandaConCantidadServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public GenerarComandaConCantidadServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		Integer cantidad=Integer.parseInt(request.getParameter("cantidad"));
		itemComandaDTO item=(itemComandaDTO) request.getSession().getAttribute("item");
		item.setCantidad(cantidad);
		System.out.println(cantidad);
		System.out.println(item.getPlato().getNombre());
		List<itemComandaDTO>items=(List<itemComandaDTO>) request.getSession().getAttribute("items");
		items.add(item);
		response.sendRedirect("GenerarComanda.jsp");
	}

}
